home *** CD-ROM | disk | FTP | other *** search
/ Unreal Tournament Game Programming for Teens / UnrealTournamentGameProgrammingForTeens.iso / Chapter Files / Chapter08 / Story.txt < prev   
Encoding:
Text File  |  2006-11-01  |  2.5 KB  |  77 lines

  1. //=============================================================================
  2. // Story.
  3. // See Story.txt
  4. //=============================================================================
  5. class Story extends Actor placeable;
  6.  
  7.    //#1  Declare an instance of the class
  8.    //    in class scope
  9.  
  10.    var private string ActionMessage;
  11.    var private int Next;
  12.    var private Array<string> Story;
  13.  
  14.  
  15.    // Goes in MakeMessage
  16.    public function string TellStory(){
  17.        local string StoryLine;
  18.        StoryLine = GetLineOfStory();
  19.        return StoryLine;
  20.    }
  21.    
  22.    // Goes PostBeginPlay
  23.    public function MakeStory(){
  24.         CreateStory();
  25.    }
  26.  
  27.    private function CreateStory(){
  28.       // Assign text values to elements
  29.       Story[0]= "In a village";
  30.       Story[1]= "Once there lived a holy man";
  31.       Story[2]= "He was poor";
  32.       Story[3]= "His house had a dirt floor";
  33.       Story[4]= "His house had a stove";
  34.       Story[5]= "This man had a dream";
  35.       Story[6]= "Three times he had the dream";
  36.       Story[7]= "And so he thought it from God";
  37.       Story[8]= "Of going to a city";
  38.       Story[9]= "And a palace in the city";
  39.       Story[10]= "Where he, poor man";
  40.       Story[11]= "Would find a treasure";
  41.       Story[12]= "He went to the city";
  42.       Story[13]= "It was far away";
  43.       Story[14]= "And in the city he found the palace";
  44.       Story[15]= "It was well guarded";
  45.       Story[16]= "And a guard stopped him ";
  46.       Story[17]= "\"What are you doing here?\" the guard demanded ";
  47.       Story[18]= "\"I had a dream to come here, to this palace";
  48.       Story[19]= "\"Do not be foolish, said the guard";
  49.       Story[20]= "\"I once had a dream that a poor holy man would come here";
  50.       Story[21]= "\"And I would follow him home, to a village far away";
  51.       Story[22]= "\"And behind his stove would in his wretched home ";
  52.       Story[23]= "\"A treasure would be buried ";
  53.       Story[24]= "\"Go home, old one, and do not believe foolish dreams.\"";
  54.       Story[25]= "So the holy man thanked the guard.";
  55.       Story[26]= "After many days, he arrived home.";
  56.       Story[27]= "Behind his stove he started digging.";
  57.       Story[28]= "Soon he found the buried treasure.";
  58.    }
  59.    
  60.    private function string GetLineOfStory(){
  61.       local string TMessage;
  62.      // Retrieve an element from the array
  63.       if(Next < Story.Length){
  64.          TMessage = Story[Next];
  65.          Next++;
  66.       }else{
  67.          Next = 0;
  68.       }
  69.       return TMessage;
  70.    }
  71.    
  72.    
  73.    
  74.    
  75.    
  76.    
  77.